package com.ztjy.sys.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ztjy.bean.Area;
import com.ztjy.bean.City;
import com.ztjy.bean.Province;
import com.ztjy.sys.biz.AreaBiz;
import com.ztjy.sys.dao.AreaDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 区域业务逻辑
 */
@Service
public class AreaBizImpl implements AreaBiz {
    @Autowired
    private AreaDao areaDao;

    @Override
    public Province findProvinceById(Integer id) {
        return areaDao.findProvinceById(id);
    }

    @Override
    public List<Province> findProvinceAll() {
        return areaDao.findAllProvince();
    }

    @Override
    public City findCityById(Integer id) {
        return areaDao.findCityById(id);
    }

    @Override
    public List<City> findAllCity() {
        return areaDao.findAllCity();
    }

    @Override
    public PageInfo<Area> findProvinceAndCity(String pname, String cname, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<Area> provinceAndCity = areaDao.findProvinceAndCity(pname, cname);
        PageInfo<Area> pageInfo = new PageInfo<Area>(provinceAndCity);
        return pageInfo;
    }

    @Override
    public List<City> findCitiesByPId(Integer pid) {
        return areaDao.findCitiesByPId(pid);
    }
}
